# 递归
import timeit
def convertToBase7(num: int) -> str:
    if num < 0:
        return "-" + convertToBase7(-num)
    if num < 7:
        return str(num)
    _ = convertToBase7(num//7)
    o = str(num%7)
    return convertToBase7(num // 7) + str(num % 7)


# 迭代
def _convertToBase7(num: int) -> str:
    x = abs(num)
    ans = []
    while x >= 7:
        x,remain = divmod(x,7)
        ans.append(str(remain))
    ans.append(str(x))
    if num <0:
        return "-"+"".join(ans[::-1])
    else:
        return "".join(ans[::-1])

print(timeit.timeit(convertToBase7(110000032)))

print(timeit.timeit(convertToBase7(110000032)))
